package com.example.repluginhostmain;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.jeremyliao.liveeventbus.LiveEventBus;
import com.qihoo360.replugin.RePlugin;


/**
 * 主宿主
 */
public class MainActivity extends AppCompatActivity {
    private TextView down;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        down=  findViewById(R.id.down);
    }

    public void onJump(View view) {
//        Intent intent= RePlugin.createIntent("replugin", "com.example.myapplication.MainActivity");
//        intent.putExtra("name","传值啦");
//        RePlugin.startActivity(this,intent);
        MMCPlugin.getInstance().openPlugin(this, "Test",
                "com.example.plugin_lib.MainActivity", new MMCPlugin.InstallListener() {
            @Override
            public void onInstalling(int progress) {
                down.setText("正在下载插件：" + progress + "%");
                if (progress == 100) {
                    down.setText("正在安装插件...");
                }
            }

            @Override
            public void onFail(String msg) {
            }

            @Override
            public void onSuccess() {
                down.setClickable(true);
                down.setText("打开插件");
            }
        });
    }

    public void onOpen(View view) {



//        RePlugin.startActivity(MainActivity.this,
//                RePlugin.createIntent("image", "com.xq.imageplugindemo.MainActivity"));
    }
}